package com.caigou.component;

import com.caigou.bean.cms.entity.*;
import com.caigou.bean.empire.entity.EmpireSyncArticleData;
import com.caigou.bean.vo.EsArticleMqVO;
import com.caigou.enums.Constant;
import com.caigou.mapper.cms.*;
import com.caigou.service.ArticleService;
import com.caigou.util.PinyinUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Slf4j
@Component
public class EmpireDataSyncComponent {
    @Resource
    private RedisComponent redisComponent;
    @Resource
    private SnowflakeComponent snowflakeComponent;
    @Resource
    private AmqpTemplate amqpTemplate;
    @Resource
    private HtmlDetailBuilderComponent htmlDetailBuilderComponent;
    @Resource
    private HtmlHomePageBuilderComponent htmlHomePageBuilderComponent;
    @Resource
    private ArticleSyncDataMapper articleSyncDataMapper;
    @Resource
    private UserBaseInfoMapper userBaseInfoMapper;
    @Resource
    private ArticlePromoterMapper articlePromoterMapper;
    @Resource
    private ArticleKeywordMapper articleKeywordMapper;
    @Resource
    private ArticleMapper articleMapper;
    @Resource
    private ArticleInformationMapper articleInformationMapper;
    @Resource
    private ArticleTitleMapper articleTitleMapper;
    @Resource
    private ChannelDataMapper channelDataMapper;
    @Resource
    private ArticleService articleService;
    @Resource
    private RabbitProducer rabbitProducer;
    @Resource
    private RedisObjectComponent redisObjectComponent;

    @Value("${domain}")
    private String domain;

    public void disposeData(EmpireSyncArticleData info, int disposeType){
        // 获取当前帝国数据是否在新库内
        Article article = articleMapper.loadArticleByEmpire(Integer.valueOf(info.getId()));
        if (null == article){// 如果当前数据存在于新库内将不再更新
            ArticleSyncData articleSyncData = new ArticleSyncData();
            try{
                // 判定应该自动发布到某个频道
                String plateId = "0";
                String[] defaultKeyword = new String[3];
                switch (info.getArticlePlateId()){
                    case "269":// 采购人/优秀采购人(269)
                    case "270":// 采购人/部委在线(270)
                    case "271":// 采购人/省市联播(271)
                    case "272":// 采购人/官员观点(272)
                        // 关键词未填写的关键词处理
                        defaultKeyword[0] = "采购人";
                        switch (info.getArticlePlateId()) {
                            case "269":
                                defaultKeyword[1] = "优秀采购人";
                                break;
                            case "270":
                                defaultKeyword[1] = "部委在线";
                                break;
                            case "271":
                                defaultKeyword[1] = "省市联播";
                                break;
                            case "272":
                                defaultKeyword[1] = "官员观点";
                                break;
                        }
                        // 自动发布到采购人/重要资讯/采购人频道
                        plateId = "102010101";
                        break;
                    case "278":// 采购人/专题(278)
                        defaultKeyword[0] = "采购人";
                        // 自动发布到采购人/次要资讯/推荐专题
                        plateId = "102010203";
                        break;
                    case "246":// 监管/监管新动作(246)
                        defaultKeyword[0] = "监管";
                        defaultKeyword[1] = "监管新动作";
                        defaultKeyword[2] = "政策发布";
                        // 自动发布到监管/重要资讯/政策发布
                        plateId = "104010101";
                        break;
                    case "247":// 监管/厅长谈采购(247)
                    case "248":// 监管/局长谈采购(248)
                    case "249":// 监管/官员观点(249)
                        defaultKeyword[0] = "监管";
                        switch (info.getArticlePlateId()) {
                            case "247":
                                defaultKeyword[1] = "厅长谈采购";
                                defaultKeyword[2] = "人物观点";
                                break;
                            case "248":
                                defaultKeyword[1] = "局长谈采购";
                                defaultKeyword[2] = "人物观点";
                                break;
                            case "249":
                                defaultKeyword[1] = "官员观点";
                                defaultKeyword[2] = "人物观点";
                                break;
                        }
                        // 自动发布到监管/重要资讯/人物观点
                        plateId = "104010102";
                        break;
                    case "251":// 监管/新政解读(251)
                        defaultKeyword[0] = "监管";
                        defaultKeyword[1] = "新政解读";
                        defaultKeyword[2] = "新规解读";
                        // 自动发布到监管/次要咨询/新规解读
                        plateId = "104010201";
                        break;
                    case "255":// 监管专题(255)
                        defaultKeyword[0] = "监管";
                        // 自动发布到监管/次要咨询/推荐专题
                        plateId = "104010202";
                        break;
                    case "252":// 监管/法规制度(252)
                        defaultKeyword[0] = "监管";
                        defaultKeyword[1] = "法规制度";
                        defaultKeyword[2] = "法律法规";
                        // 自动发布到监管/资讯列表/法律法规
                        plateId = "104010301";
                        break;
                    case "281":// 军队/法规制度(281)
                        defaultKeyword[0] = "军队";
                        defaultKeyword[1] = "法规制度";
                        defaultKeyword[2] = "新政解读";
                        // 自动发布到军队/重要资讯/新政解读
                        plateId = "106010101";
                        break;
                    case "457":// 首页标讯/军队标讯(457)
                        defaultKeyword[0] = "军队标讯";
                        // 自动发布到军队/重要资讯/军队标讯
                        plateId = "106010102";
                        break;
                    case "287":// 军队/专题(287)
                        defaultKeyword[0] = "军队";
                        // 自动发布到军队/次要资讯/专题
                        plateId = "106010201";
                        break;
                    case "280":// 军队/军队风采(280)
                        defaultKeyword[0] = "军队";
                        defaultKeyword[1] = "军队风采";
                        // 自动发布到军队/次要资讯/资讯
                        plateId = "106010202";
                        break;
                    case "260":// 操作/案例点评(260)
                        defaultKeyword[0] = "操作";
                        defaultKeyword[1] = "案例点评";
                        // 自动发布到实务/重要资讯/案例点评
                        plateId = "103010101";
                        break;
                    case "259":// 操作/精品项目(259)
                        defaultKeyword[0] = "操作";
                        defaultKeyword[1] = "精品项目";
                        // 自动发布到实务/重要资讯/精品项目
                        plateId = "103010102";
                        break;
                    case "261":// 操作/采购实务(261)
                        defaultKeyword[0] = "操作";
                        defaultKeyword[1] = "采购实务";
                        defaultKeyword[2] = "实务流程";
                        // 自动发布到实务/资讯列表/实务流程
                        plateId = "103010303";
                        break;
                    case "258":// 操作/中心风采(258)
                        defaultKeyword[0] = "操作";
                        defaultKeyword[1] = "中心风采";
                        defaultKeyword[2] = "采购/交易中心";
                        // 自动发布到实务/资讯列表/采购中心
                        plateId = "103010305";
                        break;
                    case "263":// 操作/中介机构(263)
                        defaultKeyword[0] = "操作";
                        defaultKeyword[1] = "中介机构";
                        defaultKeyword[2] = "社会中介";
                        // 自动发布到实务/资讯列表/社会中介
                        plateId = "103010306";
                        break;
                    case "290":// 理论/热点三人行
                    case "291":// 理论/难点探索
                    case "292":// 理论/专家疑点
                    case "293":// 理论/专家观点
                        defaultKeyword[0] = "理论";
                        switch (info.getArticlePlateId()) {
                            case "290":
                                defaultKeyword[1] = "热点三人行";
                                break;
                            case "291":
                                defaultKeyword[1] = "难点探索";
                                break;
                            case "292":
                                defaultKeyword[1] = "专家答疑";
                                break;
                            case "293":
                                defaultKeyword[1] = "专家观点";
                                break;
                        }
                        plateId = "105010101";
                        break;
                    case "328":// 政采资讯/工程采购(328)
                        defaultKeyword[0] = "工程采购";
                        // 自动发布到研究院/资讯列表/工程采购
                        plateId = "105010301";
                        break;
                    case "332":// 政采资讯/PPP动向(332)
                        defaultKeyword[0] = "PPP动向";
                        defaultKeyword[1] = "PPP";
                        // 自动发布到研究院/资讯列表/PPP
                        plateId = "105010302";
                        break;
                    case "329":// 政采资讯/服务采购(329)
                        defaultKeyword[0] = "服务采购";
                        // 自动发布到研究院/资讯列表/服务采购
                        plateId = "105010303";
                        break;
                    case "333":// 政采资讯/政府买服务(333)
                        defaultKeyword[0] = "政府买服务";
                        defaultKeyword[1] = "购买服务";
                        // 自动发布到研究院/资讯列表/购买服务
                        plateId = "105010304";
                        break;
                    case "299":// 国际/聚焦GPA(299)
                        defaultKeyword[0] = "国际";
                        defaultKeyword[1] = "聚焦GPA";
                        // 自动发布到研究院/资讯列表/聚焦GPA
                        plateId = "105010305";
                        break;
                    case "301":// 国际/法律政策(301)
                        defaultKeyword[0] = "国际";
                        defaultKeyword[1] = "法律政策";
                        defaultKeyword[2] = "国外法规";
                        // 自动发布到研究院/资讯列表/国外法规
                        plateId = "105010305";
                        break;
                    case "63":// IT采购网/IT采购要闻(63)
                    case "89":// IT采购网/大标追踪(89)
                    case "92":// IT采购网/中标排行(92)
                        switch (info.getArticlePlateId()) {
                            case "63":
                                defaultKeyword[0] = "IT采购网";
                                break;
                            case "89":
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "大标追踪";
                                break;
                            case "92":
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "中标排行";
                                break;
                        }
                        // 自动发布到IT/行业资讯/要闻
                        plateId = "108010101";
                        break;
                    case "96":// IT采购网/专题(96)
                        defaultKeyword[0] = "IT采购网";
                        // 自动发布到IT/行业资讯/专题
                        plateId = "108010102";
                        break;
                    case "421":// IT采购网/IT精品展厅(421)
                        defaultKeyword[0] = "IT采购网";
                        defaultKeyword[1] = "IT精品展厅";
                        defaultKeyword[2] = "精品店";
                        // 自动发布到IT/推荐位置3/精品店
                        plateId = "108020301";
                        break;
                    case "2":// 电梯/企业大事(2)
                    case "3":// 电梯/行业大势(3)
                    case "4":// 电梯/安全聚焦(4)
                    case "5":// 电梯/采购视角(5)
                    case "8":// 电梯/人物(8)
                        defaultKeyword[0] = "电梯";
                        switch (info.getArticlePlateId()) {
                            case "2":
                                defaultKeyword[1] = "企业大事";
                                break;
                            case "3":
                                defaultKeyword[1] = "行业大势";
                                break;
                            case "4":
                                defaultKeyword[1] = "安全聚焦";
                                break;
                            case "5":
                                defaultKeyword[1] = "采购视角";
                                break;
                            case "8":
                                defaultKeyword[1] = "人物";
                                break;
                        }
                        // 自动发布到电梯/行业资讯/要闻
                        plateId = "109010101";
                        break;
                    case "7":// 电梯/专题报道(7)
                        defaultKeyword[0] = "电梯";
                        // 自动发布到电梯/行业资讯/专题
                        plateId = "109010102";
                        break;
                    case "6":// 电梯/政策法规(6)
                        defaultKeyword[0] = "电梯";
                        defaultKeyword[1] = "政策法规";
                        defaultKeyword[2] = "政策";
                        // 自动发布到电梯/行业资讯/政策
                        plateId = "109010103";
                        break;
                    case "13":// 电梯/曝光台(13)
                        defaultKeyword[0] = "电梯";
                        defaultKeyword[1] = "曝光台";
                        defaultKeyword[2] = "黑名单";
                        // 自动发布到电梯/行业资讯/黑名单
                        plateId = "109010105";
                        break;
                    case "180":// 家具/设计(180)
                    case "179":// 家具/企业(179)
                    case "40":// 家具/行业(40)
                    case "181":// 家具/人物(181)
                        defaultKeyword[0] = "家具";
                        switch (info.getArticlePlateId()) {
                            case "180":
                                defaultKeyword[1] = "设计";
                                break;
                            case "179":
                                defaultKeyword[0] = "企业";
                                break;
                            case "40":
                                defaultKeyword[0] = "行业";
                                break;
                            case "181":
                                defaultKeyword[0] = "人物";
                                break;
                        }
                        // 自动发布到家具/行业资讯/要闻
                        plateId = "111010101";
                        break;
                    case "184":// 家具/专题(184)
                        defaultKeyword[0] = "家具";
                        // 自动发布到家具/行业资讯/专题
                        plateId = "111010102";
                        break;
                    case "186":// 家具/曝光台(186)
                        defaultKeyword[0] = "家具";
                        defaultKeyword[1] = "曝光台";
                        defaultKeyword[2] = "黑名单";
                        // 自动发布到家具/行业资讯/黑名单
                        plateId = "111010105";
                        break;
                    case "122":// 空调/企业大事(122)
                    case "123":// 空调/行业大势(123)
                    case "125":// 空调/采购视角(125)
                    case "389":// 空调/焦点(389)
                    case "142":// 空调/民用空调(142)
                    case "143":// 空调/中央空调(143)
                    case "144":// 空调/精密空调(144)
                    case "145":// 空调/热泵(145)
                    case "146":// 空调/空气净化器(146)
                        defaultKeyword[0] = "空调";
                        switch (info.getArticlePlateId()) {
                            case "122":
                                defaultKeyword[1] = "企业大事";
                                break;
                            case "123":
                                defaultKeyword[1] = "行业大势";
                                break;
                            case "125":
                                defaultKeyword[1] = "采购视角";
                                break;
                            case "389":
                                defaultKeyword[1] = "焦点";
                                break;
                            case "142":
                                defaultKeyword[1] = "民用空调";
                                break;
                            case "143":
                                defaultKeyword[1] = "中央空调";
                                break;
                            case "144":
                                defaultKeyword[1] = "精密空调";
                                break;
                            case "145":
                                defaultKeyword[1] = "热泵";
                                break;
                            case "146":
                                defaultKeyword[1] = "空气净化器";
                                break;
                        }
                        // 自动发布到空调电器/行业资讯/要闻
                        plateId = "110010101";
                        break;
                    case "127":// 空调/专题报道(127)
                    case "140":// 空调/专题(140)
                        defaultKeyword[0] = "空调";
                        // 自动发布到空调电器/行业资讯/专题
                        plateId = "110010102";
                        break;
                    case "126":// 空调/政策法规(126)
                        defaultKeyword[0] = "空调";
                        defaultKeyword[1] = "政策法规";
                        defaultKeyword[2] = "政策";
                        // 自动发布到空调电器/行业资讯/政策
                        plateId = "110010103";
                        break;
                    case "137":// 空调/热词解读(137)
                    case "135":// 空调/行家论道(135)
                        defaultKeyword[0] = "空调";
                        if (info.getArticlePlateId().equals("137")){
                            defaultKeyword[1] = "热词解读";
                            defaultKeyword[2] = "解读";
                        } else if (info.getArticlePlateId().equals("135")){
                            defaultKeyword[1] = "行家论道";
                            defaultKeyword[2] = "解读";
                        }
                        // 自动发布到空调电器/行业资讯/解读
                        plateId = "110010104";
                        break;
                    case "133":// 空调/大标追踪(133)
                        defaultKeyword[0] = "空调";
                        defaultKeyword[1] = "大标追踪";
                        // 自动发布到空调电器/图表数据/图表数据
                        plateId = "110010201";
                        break;
                    case "170":// 汽车/汽车采购要闻（汽车采购）(170)
                    case "375":// 汽车/汽车资讯(375)
                    case "376":// 汽车/采购视角(376)
                    case "169":// 汽车/汽车频道首页幻灯（汽车）(169)
                    case "386":// 汽车/焦点(386)
                    case "27":// 汽车/人物(27)
                    case "28":// 汽车/展会(28)
                    case "31":// 汽车/自主品牌汽车(31)
                    case "32":// 汽车/新能源汽车(32)
                    case "33":// 汽车/执法用车(33)
                    case "34":// 汽车/专用车(34)
                    case "35":// 汽车/公交车(35)
                    case "36":// 汽车/公车租赁(36)
                        switch (info.getArticlePlateId()) {
                            case "170":
                                defaultKeyword[0] = "汽车采购";
                                break;
                            case "375":
                                defaultKeyword[0] = "汽车";
                                break;
                            case "376":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "采购视角";
                                break;
                            case "169":
                                defaultKeyword[0] = "汽车";
                                break;
                            case "386":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "焦点";
                                break;
                            case "27":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "人物";
                                break;
                            case "28":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "展会";
                                break;
                            case "31":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "自主品牌汽车";
                                break;
                            case "32":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "新能源汽车";
                                break;
                            case "33":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "执法用车";
                                break;
                            case "34":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "专用车";
                                break;
                            case "35":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "公交车";
                                break;
                            case "36":
                                defaultKeyword[0] = "汽车";
                                defaultKeyword[1] = "公车租赁";
                                break;
                        }
                        // 自动发布到汽车/行业资讯/要闻
                        plateId = "107010101";
                        break;
                    case "26":// 汽车/专题(26)
                        defaultKeyword[0] = "汽车";
                        // 自动发布到汽车/行业资讯/专题
                        plateId = "107010102";
                        break;
                    case "20":// 汽车/大标追踪(20)
                        defaultKeyword[0] = "汽车";
                        defaultKeyword[1] = "大标追踪";
                        // 自动发布到汽车/图表数据/图表数据
                        plateId = "107010201";
                        break;
                    case "22":// 汽车/新车上市(22)
                        defaultKeyword[0] = "汽车";
                        defaultKeyword[1] = "新车上市";
                        // 自动发布到汽车/企业宣传/新车上市
                        plateId = "107010301";
                        break;
                    case "177":// 汽车/精品展厅(177)
                        defaultKeyword[0] = "汽车";
                        defaultKeyword[1] = "精品展厅";
                        // 自动发布到汽车/企业宣传/图例展示
                        plateId = "107010302";
                        break;
                    case "178":// 汽车/试驾评测(178)
                    case "25":// 汽车/视频(25)
                        defaultKeyword[0] = "汽车";
                        if (info.getArticlePlateId().equals("178")){
                            defaultKeyword[1] = "试驾评测";
                            defaultKeyword[2] = "主播荐车";
                        } else if (info.getArticlePlateId().equals("25")){
                            defaultKeyword[1] = "视频";
                            defaultKeyword[2] = "主播荐车";
                        }
                        // 自动发布到汽车/推荐位置3/主播荐车
                        plateId = "107020301";
                        break;
                    case "444":// 亚利聊政采-政府采购信息网/往期回顾(444)
                        defaultKeyword[0] = "亚利聊政采";
                        // 自动发布到全局推荐/全局推荐位2/亚利聊政采
                        plateId = "100010201";
                        break;
                    case "273":// 采购人/部门采购(273)
                    case "274":// 采购人/部门新规(274)
                    case "275":// 采购人/精品项目(275)
                    case "276":// 采购人/图片(276)
                    case "277":// 采购人/视频(277)
                    case "279":// 采购人/热词解读(279)
                    case "282":// 军队/操作实务(282)
                    case "283":// 军队/理论探索(283)
                    case "284":// 军队/领军人物(284)
                    case "285":// 军队/案例点评(285)
                    case "288":// 军队/图片(288)
                    case "286":// 军队/视频(286)
                    case "289":// 军队/热词解读(289)
                    case "352":// 首页/首页幻灯片（政府采购）(352)
                    case "353":// 首页/首页要闻（政府采购）(353)
                    case "354":// 首页/首页专题(354)
                    case "355":// 首页/首页人物（人物）(355)
                    case "356":// 首页/首页视频（视频）(356)
                    case "357":// 首页/首页图片（图片）(357)
                    case "358":// 首页/首页品牌会议（品牌会议）(358)
                    case "384":// 政采资讯/报纸文章(384)
                    case "331":// 政采资讯/政采要闻(331)
                    case "330":// 政采资讯/政采资讯幻灯片(330)
                    case "95":// IT采购网/图片(95)
                    case "175":// IT采购网/视频(175)
                    case "98":// IT采购网/展会(98)
                    case "64":// IT采购网/产业(64)
                    case "101":// IT采购网/计算机(101)
                    case "102":// IT采购网/服务器(102)
                    case "103":// IT采购网/办公外设(103)
                    case "104":// IT采购网/显示器(104)
                    case "105":// IT采购网/网络设备(105)
                    case "107":// IT采购网/基础软件(107)
                    case "108":// IT采购网/应用软件(108)
                    case "109":// IT采购网/云计算(109)
                    case "110":// IT采购网/物联网(110)
                    case "111":// IT采购网/智慧城市(111)
                    case "9":// 电梯/视频(9)
                    case "11":// 电梯/图片(11)
                    case "14":// 电梯/活动(14)
                    case "15":// 电梯/展会(15)
                    case "17":// 电梯/中标排行(17)
                    case "385":// 电梯/焦点(385)
                    case "182":// 家具/行家论道(182)
                    case "202":// 家具/大标追踪(202)
                    case "201":// 家具/中标排行(201)
                    case "185":// 家具/展会(185)
                    case "183":// 家具/热词解读(183)
                    case "187":// 家具/视频(187)
                    case "300":// 国际/国外做法(300)
                    case "302":// 国际/国际交流(302)
                    case "303":// 国际/国外协会(303)
                    case "304":// 国际/公共采购(304)
                    case "308":// 国际/视频(308)
                    case "309":// 国际/专题(309)
                    case "305":// 国际/出访归来(305)
                    case "306":// 国际/案例分析(306)
                    case "307":// 国际/图片(307)
                    case "310":// 国际/人物(310)
                    case "311":// 国际/热词解读(311)
                    case "318":// 国际/焦点(318)
                    case "23":// 汽车/行家论道(23)
                    case "24":// 汽车/靓车美图(24)
                    case "29":// 汽车/热词解读(29)
                    case "128":// 空调/企业展厅(128)
                    case "138":// 空调/展会(138)
                    case "139":// 空调/人物(139)
                    case "141":// 空调/活动(141)
                    case "370":// 空调/品牌客户(370)
                    case "262":// 操作/采购故事(262)
                    case "264":// 操作/图片(264)
                    case "265":// 操作/视频(265)
                    case "266":// 操作/专题(266)
                    case "267":// 操作/人物(267)
                    case "268":// 操作/热词解读(268)
                    case "314":// 操作/焦点(314)
                    case "250":// 监管/一线采风(250)
                    case "253":// 监管/图片(253)
                    case "254":// 监管/视频(254)
                    case "256":// 监管/人物(256)
                    case "257":// 监管/热词解读(257)
                    case "294":// 理论/视频
                    case "295":// 理论/人物
                    case "297":// 理论/图片
                    case "298":// 理论/热词解读
                    case "317":// 理论/焦点
                        switch (info.getArticlePlateId()){
                            // 再次判定处理关键词信息
                            case "273":// 采购人/部门采购(273)
                                defaultKeyword[0] = "采购人";
                                defaultKeyword[1] = "部门采购";
                                break;
                            case "274":// 采购人/部门新规(274)
                                defaultKeyword[0] = "采购人";
                                defaultKeyword[1] = "部门新规";
                                break;
                            case "275":// 采购人/精品项目(275)
                                defaultKeyword[0] = "采购人";
                                defaultKeyword[1] = "精品项目";
                                break;
                            case "276":// 采购人/图片(276)
                                defaultKeyword[0] = "采购人";
                                defaultKeyword[1] = "图片";
                                break;
                            case "277":// 采购人/视频(277)
                                defaultKeyword[0] = "采购人";
                                defaultKeyword[1] = "视频";
                                break;
                            case "279":// 采购人/热词解读(279)
                                defaultKeyword[0] = "采购人";
                                defaultKeyword[1] = "热词解读";
                                break;
                            case "282":// 军队/操作实务(282)
                                defaultKeyword[0] = "军队";
                                defaultKeyword[1] = "操作实务";
                                break;
                            case "283":// 军队/理论探索(283)
                                defaultKeyword[0] = "军队";
                                defaultKeyword[1] = "理论探索";
                                break;
                            case "284":// 军队/领军人物(284)
                                defaultKeyword[0] = "军队";
                                defaultKeyword[1] = "领军人物";
                                break;
                            case "285":// 军队/案例点评(285)
                                defaultKeyword[0] = "军队";
                                defaultKeyword[1] = "案例点评";
                                break;
                            case "288":// 军队/图片(288)
                                defaultKeyword[0] = "军队";
                                defaultKeyword[1] = "图片";
                                break;
                            case "286":// 军队/视频(286)
                                defaultKeyword[0] = "军队";
                                defaultKeyword[1] = "视频";
                                break;
                            case "289":// 军队/热词解读(289)
                                defaultKeyword[0] = "军队";
                                defaultKeyword[1] = "热词解读";
                                break;
                            case "352":// 首页/首页幻灯片（政府采购）(352)
                            case "353":// 首页/首页要闻（政府采购）(353)
                            case "354":// 首页/首页专题(354)
                                defaultKeyword[0] = "政采资讯";
                                break;
                            case "355":// 首页/首页人物（人物）(355)
                                defaultKeyword[0] = "人物";
                                break;
                            case "356":// 首页/首页视频（视频）(356)
                                defaultKeyword[0] = "视频";
                                break;
                            case "357":// 首页/首页图片（图片）(357)
                                defaultKeyword[0] = "图片";
                                break;
                            case "358":// 首页/首页品牌会议（品牌会议）(358)
                                defaultKeyword[0] = "品牌会议";
                                break;
                            case "384":// 政采资讯/报纸文章(384)
                                defaultKeyword[0] = "政采资讯";
                                defaultKeyword[1] = "报纸文章";
                                break;
                            case "331":// 政采资讯/政采要闻(331)
                                defaultKeyword[0] = "政采资讯";
                                defaultKeyword[1] = "政采要闻";
                                break;
                            case "330":// 政采资讯/政采资讯幻灯片(330)
                                defaultKeyword[0] = "政采资讯";
                                break;
                            case "95":// IT采购网/图片(95)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "图片";
                                break;
                            case "175":// IT采购网/视频(175)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "视频";
                                break;
                            case "98":// IT采购网/展会(98)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "展会";
                                break;
                            case "64":// IT采购网/产业(64)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "产业";
                                break;
                            case "101":// IT采购网/计算机(101)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "计算机";
                                break;
                            case "102":// IT采购网/服务器(102)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "服务器";
                                break;
                            case "103":// IT采购网/办公外设(103)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "办公外设";
                                break;
                            case "104":// IT采购网/显示器(104)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "显示器";
                                break;
                            case "105":// IT采购网/网络设备(105)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "网络设备";
                                break;
                            case "107":// IT采购网/基础软件(107)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "基础软件";
                                break;
                            case "108":// IT采购网/应用软件(108)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "应用软件";
                                break;
                            case "109":// IT采购网/云计算(109)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "云计算";
                                break;
                            case "110":// IT采购网/物联网(110)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "物联网";
                                break;
                            case "111":// IT采购网/智慧城市(111)
                                defaultKeyword[0] = "IT采购网";
                                defaultKeyword[1] = "智慧城市";
                                break;
                            case "9":// 电梯/视频(9)
                                defaultKeyword[0] = "电梯";
                                defaultKeyword[1] = "视频";
                                break;
                            case "11":// 电梯/图片(11)
                                defaultKeyword[0] = "电梯";
                                defaultKeyword[1] = "图片";
                                break;
                            case "14":// 电梯/活动(14)
                                defaultKeyword[0] = "电梯";
                                defaultKeyword[1] = "活动";
                                break;
                            case "15":// 电梯/展会(15)
                                defaultKeyword[0] = "电梯";
                                defaultKeyword[1] = "展会";
                                break;
                            case "17":// 电梯/中标排行(17)
                                defaultKeyword[0] = "电梯";
                                defaultKeyword[1] = "中标排行";
                                break;
                            case "385":// 电梯/焦点(385)
                                defaultKeyword[0] = "电梯";
                                defaultKeyword[1] = "焦点";
                                break;
                            case "182":// 家具/行家论道(182)
                                defaultKeyword[0] = "家具";
                                defaultKeyword[1] = "行家论道";
                                break;
                            case "202":// 家具/大标追踪(202)
                                defaultKeyword[0] = "家具";
                                defaultKeyword[1] = "大标追踪";
                                break;
                            case "201":// 家具/中标排行(201)
                                defaultKeyword[0] = "家具";
                                defaultKeyword[1] = "中标排行";
                                break;
                            case "185":// 家具/展会(185)
                                defaultKeyword[0] = "家具";
                                defaultKeyword[1] = "展会";
                                break;
                            case "183":// 家具/热词解读(183)
                                defaultKeyword[0] = "家具";
                                defaultKeyword[1] = "热词解读";
                                break;
                            case "187":// 家具/视频(187)
                                defaultKeyword[0] = "家具";
                                defaultKeyword[1] = "视频";
                                break;
                            case "300":// 国际/国外做法(300)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "国外做法";
                                break;
                            case "302":// 国际/国际交流(302)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "国际交流";
                                break;
                            case "303":// 国际/国外协会(303)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "国外协会";
                                break;
                            case "304":// 国际/公共采购(304)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "公共采购";
                                break;
                            case "308":// 国际/视频(308)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "视频";
                                break;
                            case "309":// 国际/专题(309)
                                defaultKeyword[0] = "国际";
                                break;
                            case "305":// 国际/出访归来(305)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "出访归来";
                                break;
                            case "306":// 国际/案例分析(306)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "案例分析";
                                break;
                            case "307":// 国际/图片(307)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "图片";
                                break;
                            case "310":// 国际/人物(310)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "人物";
                                break;
                            case "311":// 国际/热词解读(311)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "热词解读";
                                break;
                            case "318":// 国际/焦点(318)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "焦点";
                                break;
                            case "23":// 汽车/行家论道(23)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "行家论道";
                                break;
                            case "24":// 汽车/靓车美图(24)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "靓车美图";
                                break;
                            case "29":// 汽车/热词解读(29)
                                defaultKeyword[0] = "国际";
                                defaultKeyword[1] = "热词解读";
                                break;
                            case "128":// 空调/企业展厅(128)
                                defaultKeyword[0] = "空调";
                                defaultKeyword[1] = "企业展厅";
                                break;
                            case "138":// 空调/展会(138)
                                defaultKeyword[0] = "空调";
                                defaultKeyword[1] = "展会";
                                break;
                            case "139":// 空调/人物(139)
                                defaultKeyword[0] = "空调";
                                defaultKeyword[1] = "人物";
                                break;
                            case "141":// 空调/活动(141)
                                defaultKeyword[0] = "空调";
                                defaultKeyword[1] = "活动";
                                break;
                            case "370":// 空调/品牌客户(370)
                                defaultKeyword[0] = "空调";
                                defaultKeyword[1] = "品牌客户";
                                break;
                            case "262":// 操作/采购故事(262)
                                defaultKeyword[0] = "操作";
                                defaultKeyword[1] = "采购故事";
                                break;
                            case "264":// 操作/图片(264)
                                defaultKeyword[0] = "操作";
                                defaultKeyword[1] = "图片";
                                break;
                            case "265":// 操作/视频(265)
                                defaultKeyword[0] = "操作";
                                defaultKeyword[1] = "视频";
                                break;
                            case "266":// 操作/专题(266)
                                defaultKeyword[0] = "操作";
                                break;
                            case "267":// 操作/人物(267)
                                defaultKeyword[0] = "操作";
                                defaultKeyword[1] = "人物";
                                break;
                            case "268":// 操作/热词解读(268)
                                defaultKeyword[0] = "操作";
                                defaultKeyword[1] = "热词解读";
                                break;
                            case "314":// 操作/焦点(314)
                                defaultKeyword[0] = "操作";
                                defaultKeyword[1] = "焦点";
                                break;
                            case "250":// 监管/一线采风(250)
                                defaultKeyword[0] = "监管";
                                defaultKeyword[1] = "一线采风";
                                break;
                            case "253":// 监管/图片(253)
                                defaultKeyword[0] = "监管";
                                defaultKeyword[1] = "图片";
                                break;
                            case "254":// 监管/视频(254)
                                defaultKeyword[0] = "监管";
                                defaultKeyword[1] = "视频";
                                break;
                            case "256":// 监管/人物(256)
                                defaultKeyword[0] = "监管";
                                defaultKeyword[1] = "人物";
                                break;
                            case "257":// 监管/热词解读(257)
                                defaultKeyword[0] = "监管";
                                defaultKeyword[1] = "热词解读";
                                break;
                            case "294":// 理论/视频
                                defaultKeyword[0] = "理论";
                                defaultKeyword[1] = "视频";
                                break;
                            case "295":// 理论/人物
                                defaultKeyword[0] = "理论";
                                defaultKeyword[1] = "人物";
                                break;
                            case "297":// 理论/图片
                                defaultKeyword[0] = "理论";
                                defaultKeyword[1] = "图片";
                                break;
                            case "298":// 理论/热词解读
                                defaultKeyword[0] = "理论";
                                defaultKeyword[1] = "热词解读";
                                break;
                            case "317":// 理论/焦点
                                defaultKeyword[0] = "理论";
                                defaultKeyword[1] = "焦点";
                                break;
                        }
                        // 自动发布到RSS频道
                        plateId = "-1";
                        break;
                }
                // 如果不在同步范围内，则跳过此内容
                if (plateId.equals("0")){
                    // 当前数据不在同步范围内，不进行数据同步--同步失败，保存同步失败的数据，用于手动补充
                    String errMessage = "布局不在处理范围内";
                    log.error(errMessage);
                    articleSyncData.setErrId(info.getId());
                    articleSyncData.setErrMessage(errMessage);
                    articleSyncDataMapper.saveArticleSyncData(articleSyncData);
                    // 如果保存结束的时候，设定最后处理的ID编号，用于下次判定启动的ID
                    redisComponent.set("empireDataSyncLastTime", info.getArticleUpdateTime());
                    return;
                }
                StringBuilder articleKeyword = new StringBuilder();
                // 开始遍历获取文章数据--所有文章类型都将保存为资讯类型
                String userId = userBaseInfoMapper.loadUserIdByPinyin(info.getArticleCreateUser());
                if (null == userId || userId.equals("")) userId = "b3b33c0a52ed4406a48876e6e9fd21e8";
                // 作者字段处理（字符串处理过后--判定进行作者新增）
                String articleAuthor = "";
                if (null != info.getArticleAuthor() && !info.getArticleAuthor().equals("")){
                    String name = info.getArticleAuthor()
                            .trim()// 去除首位空格
                            .replaceAll("&amp;", "&")// 全局替换'&'号转义符
                            .replaceAll("&nbsp;", " ")// 去除字符中的空格符
                            .replaceAll(" +","");// 去掉所有空格
                    ArticlePromoter articlePromoter = articlePromoterMapper.articlePromoterExist(name);
                    if (null == articlePromoter){
                        // 如果当前名称的作者不存在，则进行新作者数据的保存
                        articlePromoter = new ArticlePromoter();
                        articlePromoter.setName(name);
                        articlePromoter.setIsForbid(1);
                        try {
                            articlePromoterMapper.insertSelective(articlePromoter);
                            articleAuthor = articlePromoter.getId().toString();
                        } catch (DataIntegrityViolationException exception){
                            articleAuthor = "0";
                        }
                    } else {
                        articleAuthor = articlePromoter.getId().toString();
                    }
                }
                List<String> defaultKeywordList=new ArrayList<String>();
                for(int i = 0; i < defaultKeyword.length; i++){
                    if(defaultKeyword[i]==null||"".equals(defaultKeyword[i].trim().toString())){
                    }else{
                        defaultKeywordList.add(defaultKeyword[i]);
                    } }
                String []newArray=new String[defaultKeywordList.size()];
                for(int i=0;i<newArray.length;i++){
                    newArray[i]=defaultKeywordList.get(i);
                }
                // 关键词处理
                for (String word: newArray){
                    if (!word.equals("")){
                        ArticleKeyword keyword = articleKeywordMapper.findArticleKeywordsByKeyword(word);
                        if (null == keyword){
                            keyword = new ArticleKeyword();
                            keyword.setKeyword(word);
                            String initials = PinyinUtil.getPinyinInitials(word);
                            keyword.setCapital(initials);
                            keyword.setStaticAddress(domain+"/web/tag-list.html?id=");
                            keyword.setCreateTime(new Date());
                            keyword.setUpdateTime(new Date());
                            articleKeywordMapper.insertSelective(keyword);
                        }
                        articleKeyword.append(keyword.getId()).append(",");
                    }
                }
                if (!articleKeyword.equals("") && articleKeyword.length() > 1) articleKeyword.deleteCharAt(articleKeyword.length() - 1);
                // 外部跳转链接处理
                int outListStatus = 0;
                String outLink = "";
                if (!info.getArticleOutLink().contains("caigou2003")){
                    // 当前地址不再本域名下，使用外链
                    outLink = info.getArticleOutLink();
                    outListStatus = 1;
                }
                // 封装请求，保存参数
                article = new Article();
                article.setArticleId(String.valueOf(snowflakeComponent.getInstance().nextId()));
                article.setArticleUserId(userId);
                article.setArticleTitle(info.getArticleTitle());
                article.setArticleAuthor(articleAuthor);
                article.setArticlePromoterStatus(0);
                article.setArticlePromoter("0");
                article.setArticleScout("");
                article.setArticleEditor("");
                // 如果大于50位，则截取50位作为来源
                article.setArticleSource(info.getArticleSource().length() > 50 ? info.getArticleSource().substring(0,50) : info.getArticleSource());
                article.setArticleKeyWord(articleKeyword.toString());
                article.setArticlePaperStatus(-1);
                article.setArticleWeChatStatus(-1);
                article.setArticleEBookStatus(-1);
                article.setArticleOutLinkStatus(outListStatus);
                article.setArticleOutLink(outLink);
                article.setArticleInfoStatus(0);
                article.setArticleInfo(info.getArticleInfo());
                article.setArticleUrl("");
                article.setArticleAnnotationStatus(0);
                article.setArticleType(1);
                article.setArticleLikeRecommendStatus(0);
                article.setArticleRecommendType(1);
                article.setArticleRecommend("");
                article.setArticleVip(0);
                article.setArticleVipType(0);
                article.setArticleMoney(0);
                article.setArticlePrice(0);
                article.setArticleLikeType(1);
                article.setArticleLikeCount(0);
                article.setArticleClickCount(0);
                article.setArticleVisitCount(0);
                article.setArticleCommentId(article.getArticleId());
                article.setArticleCommentStatus(0);
                article.setArticleStatus(1);
                article.setArticleShareImage("");
                article.setEmpireId(Integer.valueOf(info.getId()));
                if (!info.getArticleTime().equals("0")){
                    Date date = new Date(Long.valueOf(info.getArticleTime()) * 1000);
                    article.setCreateTime(date);
                    article.setUpdateTime(date);
                } else {
                    article.setCreateTime(new Date());
                    article.setUpdateTime(new Date());
                }
                articleMapper.saveArticleData2(article);
                // 修改文章的点击量
                articleMapper.updateArticleClickCount(article.getArticleId(),info.getArticleClickCount());
                // 保存文章详情页数据
                ArticleInformation articleInformation = new ArticleInformation();
                articleInformation.setArticleId(article.getArticleId());
                articleInformation.setArticleContent(disposeContent(info.getArticleContent()));
                articleInformationMapper.saveArticleInformationData(articleInformation);
                // 保存默认标题
                ArticleTitle articleTitle = new ArticleTitle();
                articleTitle.setArticleId(article.getArticleId());
                articleTitle.setArticleTitleType(-1);
                articleTitle.setArticleTitle(article.getArticleTitle());
                articleTitle.setArticleImageId(0);
                articleTitle.setArticleImage("");
                articleTitle.setArticleImageAlt("");
                articleTitle.setArticleTitleStatus(1);
                articleTitleMapper.saveArticleTitleData(articleTitle);
                // 进行频道自动发布
                int plateStatus = channelDataMapper.loadArticleReleaseStatus(article.getArticleId(), plateId);
                if (plateStatus == 0){
                    // 保存频道更多列表数据
                    ChannelData channelData = new ChannelData();
                    channelData.setTitleType(-1);
                    channelData.setArticleId(article.getArticleId());
                    channelData.setPlateId(plateId);
                    channelData.setDataType(1);
                    channelData.setShowIndex(0);
                    channelData.setRecommendStatus(0);
                    channelData.setStickStatus(0);
                    channelData.setLockStatus(0);
                    channelDataMapper.saveChannelData(channelData);
                }
                int rssStatus = channelDataMapper.loadArticleReleaseStatus(article.getArticleId(),"-1");
                if (rssStatus == 0){
                    // 保存RSS频道数据
                    ChannelData channelData = new ChannelData();
                    channelData.setTitleType(-1);
                    channelData.setArticleId(article.getArticleId());
                    channelData.setPlateId("-1");
                    channelData.setDataType(1);
                    channelData.setShowIndex(0);
                    channelData.setRecommendStatus(0);
                    channelData.setStickStatus(0);
                    channelData.setLockStatus(0);
                    channelDataMapper.saveChannelData(channelData);
                }
                // 生成文章静态页
                htmlDetailBuilderComponent.buildArticleHtml(article.getArticleId(),plateId.equals("-1") ? "999" : plateId );
                // 新增接口在发布状态下，发送ESMQ消息
                amqpTemplate.convertAndSend(Constant.CMS_ARTICLE_QUEUE, Collections.singletonList(new EsArticleMqVO(article.getArticleId(), Constant.UPDATE_ARTICLE)));
                // 更新
                if (article.getArticleType() != 4 && article.getArticleType() != 14) {
                    String articleContent = articleService.loadArticlePreviewData(article.getArticleId());
                    Map<String, Object> map = new HashMap<>();
                    map.put("articleId", article.getArticleId());
                    map.put("articleContent", articleContent);
                    rabbitProducer.sendDefaultMessage(map);
                }
                // 清除移动端缓存
                redisObjectComponent.del(article.getArticleId());
            } catch (Exception e){
                // 当前数据不在同步范围内，不进行数据同步--同步失败，保存同步失败的数据，用于手动补充
                String errMessage = "数据异常无法进行数据同步";
                log.error(errMessage);
                log.error(e.getMessage(), e);
                articleSyncData.setErrId(info.getId());
                articleSyncData.setErrMessage(errMessage);
                articleSyncDataMapper.saveArticleSyncData(articleSyncData);
                // 如果保存结束的时候，设定最后处理的ID编号，用于下次判定启动的ID
                if (disposeType == 0){// 填充就数据ID
                    redisComponent.set("empireDataSyncLastTime", info.getArticleUpdateTime());
                } else if (disposeType == 1){// 填充新数据ID
                    redisComponent.set("empireNewDataSyncLastTime", info.getArticleUpdateTime());
                }

            }
        } else {
            // 进行数据修改
//                article.setArticleTitle(article.getArticleTitle());
//                article.setArticleClick(Integer.valueOf(info.getArticleClickCount()));
//                article.setArticleKeyWord(article.getArticleKeyWord());
//                article.setArticleInfo(info.getArticleInfo());
//                article.setArticleSource(info.getArticleSource());
//                if (!info.getArticleTime().equals("0")){
//                    Date date = new Date(Long.valueOf(info.getArticleTime()) * 1000);
//                    article.setCreateTime(date);
//                    article.setUpdateTime(date);
//                } else {
//                    article.setCreateTime(new Date());
//                    article.setUpdateTime(new Date());
//                }
//                articleMapper.updateEmpireData(article);
//                ArticleInformation articleInformation = articleInformationMapper.loadArticleInformationData(article.getArticleId());
//                if (null == articleInformation){
//                    articleInformation = new ArticleInformation();
//                    articleInformation.setArticleId(article.getArticleId());
//                    articleInformation.setArticleContent(disposeContent(info.getArticleContent()));
//                    articleInformationMapper.saveArticleInformationData(articleInformation);
//                } else {
//                    articleInformation.setArticleId(article.getArticleId());
//                    articleInformation.setArticleContent(disposeContent(info.getArticleContent()));
//                    articleInformationMapper.updateArticleInformationData(articleInformation);
//                }
//                // 进行频道自动发布
//                int plateStatus = channelDataMapper.loadArticleReleaseStatus(article.getArticleId(), plateId);
//                if (plateStatus == 0){
//                    // 保存频道更多列表数据
//                    ChannelData channelData = new ChannelData();
//                    channelData.setTitleType(-1);
//                    channelData.setArticleId(article.getArticleId());
//                    channelData.setPlateId(plateId);
//                    channelData.setDataType(1);
//                    channelData.setShowIndex(0);
//                    channelData.setRecommendStatus(0);
//                    channelData.setStickStatus(0);
//                    channelData.setLockStatus(0);
//                    channelDataMapper.saveChannelData(channelData);
//                }
//                int rssStatus = channelDataMapper.loadArticleReleaseStatus(article.getArticleId(),-1);
//                if (rssStatus == 0){
//                    // 保存RSS频道数据
//                    ChannelData channelData = new ChannelData();
//                    channelData.setTitleType(-1);
//                    channelData.setArticleId(article.getArticleId());
//                    channelData.setPlateId(-1);
//                    channelData.setDataType(1);
//                    channelData.setShowIndex(0);
//                    channelData.setRecommendStatus(0);
//                    channelData.setStickStatus(0);
//                    channelData.setLockStatus(0);
//                    channelDataMapper.saveChannelData(channelData);
//                }
//                // 生成文章静态页
//                htmlDetailBuilderComponent.buildArticleHtml(article.getArticleId(),plateId == -1? 999 : plateId );
//                // 修改完成之后这篇文章可能被推到推荐位上，进行对应频道页的更新
//                List<ChannelData> channelDataList = channelDataMapper.loadLastChannelAllData(article.getArticleId());
//                if (null != channelDataList)
//                    // 更新文章频道页
//                    channelDataList.forEach(item -> htmlHomePageBuilderComponent.buildHomePageHtml(item.getPlateId()));
        }
        // 如果保存结束的时候，设定最后处理的ID编号，用于下次判定启动的ID
        if (disposeType == 0){
            redisComponent.set("empireDataSyncLastTime", info.getArticleUpdateTime());
        } else if (disposeType == 1){
            redisComponent.set("empireNewDataSyncLastTime", info.getArticleUpdateTime());
        }
    }

    private static String disposeContent(String cont){
        StringBuffer buffer = new StringBuffer() ;
        // style标签处理
        String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式
        Pattern p_style=Pattern.compile(regEx_style,Pattern.DOTALL + Pattern.MULTILINE);
        Matcher m_style=p_style.matcher(cont);
        cont=m_style.replaceAll(""); //过滤style标签
        // html标签处理
//        String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式
        String regEx_html="<([a-zA-Z]*)|(\\/[a-zA-Z]*)>"; //定义HTML标签的正则表达式
        Pattern p_html=Pattern.compile(regEx_html,Pattern.DOTALL + Pattern.MULTILINE);
        Matcher m_html=p_html.matcher(cont);
        while (m_html.find()) {
            // 块级元素(div、h1、h2、h3、h4、h5、h6),全部替换为自己默认的p标签元素
            String tmp = m_html.group().toLowerCase().trim();
            String v = "";
            switch (tmp) {
                case "<div":
                case "<h1":
                case "<h2":
                case "<h3":
                case "<h4":
                case "<h5":
                case "<h6":
                    v = tmp.replace("<div", "<p")
                            .replace("<h1", "<p")
                            .replace("<h2", "<p")
                            .replace("<h3", "<p")
                            .replace("<h4", "<p")
                            .replace("<h5", "<p")
                            .replace("<h6", "<p");
                    break;
                case "/div>":
                case "/h1>":
                case "/h2>":
                case "/h3>":
                case "/h4>":
                case "/h5>":
                case "/h6>":
                    v = tmp.replace("/div>", "/p>")
                            .replace("/h1>", "/p>")
                            .replace("/h2>", "/p>")
                            .replace("/h3>", "/p>")
                            .replace("/h4>", "/p>")
                            .replace("/h5>", "/p>")
                            .replace("/h6>", "/p>");
                    break;
                default:
                    v = tmp;
            }
            m_html.appendReplacement(buffer, v) ;
        }
        m_html.appendTail(buffer) ;

        // 去除转义
        cont = buffer.toString();
        cont = StringEscapeUtils.unescapeHtml4(cont);
        cont = cont.replaceAll("\\\\","");

        // 去除段首空格、空白符、空格符等
        String regex1 = ">[\\s\\p{Zs}&nbsp;]+";
        String subst1 = ">";
        Pattern pattern1 = Pattern.compile(regex1, Pattern.DOTALL + Pattern.MULTILINE);
        Matcher matcher1 = pattern1.matcher(cont);
        String result1 = matcher1.replaceAll(subst1);
        // 去除空段
        String regex2 = "<p></p>";
        String subst2 = "";
        Pattern pattern2 = Pattern.compile(regex2, Pattern.DOTALL + Pattern.MULTILINE);
        Matcher matcher2 = pattern2.matcher(result1);
        String result2 = matcher2.replaceAll(subst2);



        return "<div class='rich-text'>" + result2 + "</div>";
    }

    public String disponseInfo(String string) {
        final String regex1 = ">[\\s\\p{Zs}&nbsp;]+";// 去除段首空格、空白符、空格符等
        final String subst1 = ">";
        final Pattern pattern1 = Pattern.compile(regex1, Pattern.DOTALL + Pattern.MULTILINE);
        final Matcher matcher1 = pattern1.matcher(string);
        final String result1 = matcher1.replaceAll(subst1);

        String regex2 = "<p></p>";// 去除空段
        String subst2 = "";
        Pattern pattern2 = Pattern.compile(regex2, Pattern.DOTALL + Pattern.MULTILINE);
        Matcher matcher2 = pattern2.matcher(result1);
        String result2 = matcher2.replaceAll(subst2);

        return result2;
    }
}
